import instance from "./axios";

export const getNewsList = async (data) => {
    const result = await instance.get('/news/newsList?' + data)
    return result.data.data
}

export const getReleaseList = async () => {
    const result = await instance.post('/news/releaseList')
    return result.data.data
}

export const updateNews = async (data) => {
    const result = await instance.post('/news/updateNews', data)
    return result
}

export const getAcounts = async () => {
    const result = await instance.post('/news/selectAllCountClassReal')
    return result.data.data
}

export const orderNews = async (data: { id: number, orderNews: number }[]) => {
    return instance.post('/news/order', { list: data });

}

export const insertPublish = async (data) => {
    const result = await instance.post('/news/insertPublish', data);

    return result.data;

}

interface uploadParams {
    "url": "t",
    "id": number,
    "filename": "示例文件.",
    "size": number
}
export const upload = async (data: uploadParams) => {
    const result = await instance.post('/file/upload', data);
console.log('upload接口返回完整数据:', result);
    return result.data;

}

export const insertWaitPublish = async (data) => {
    const result = await instance.post('/news/insertWaitPublish', data);
    return result.data;
}

interface PublishReleaseParams {
    "waitPubTime": string,
    "issueTitle": string,
    "issueCoverImage": string,
    "issueDescription": string,
    "issuePublishTime": string,
    "issuePublisher": string
}
export const publishReleaseList = async (data: PublishReleaseParams) => {
    const result = await instance.post('/news/publishReleaseList', data);
    console.log('接口返回完整数据:', result);
    return result.data;
}
export const issueList = async (data: { "current": number, "currentSize": number }) => {
    const result = await instance.post('/news/issueList', data);
    console.log('issueList接口返回完整数据:', result);
    return result.data;
}
